import React from 'react';
import { connect } from 'dva';
import { WhiteSpace, Flex, List, Modal } from 'antd-mobile';
import { Link, routerRedux } from 'dva/router';
import * as services from 'services/report';
import MemberInfo from '../../../components/MemberInfo';
import { 
	ScaleReport, ScalePrograme,
	ChdScaleReport, ScaleProgrameSelect,
	HypScaleReport,
	XinScaleReport,
	TcmScaleReport,
	PreScaleReport,
	PartumScaleReport,
	DiaScaleReport,
	PrePreScaleReport,
	ScaleComment,

	AlphaReport,
	FaceReport,
	PulseReport,
	TongueReport,
 } 
from '../../../components/scale';

const { Item, Item: { Brief } } = List;
function ReportDetailPage({ location,dispatch,report, programs, member, PatientValue, comment,...rest }) {
	const {record} = location.state;
	member.birthday = location.state.report.birthday;
	member.createTime= location.state.report.createTime;
	member.age = location.state.report.age;
	member.gender = location.state.report.gender;
	member.relation = location.state.report.relation;
	member.name = location.state.report.name;
	member.title = location.state.report.title;
	member.vp =  report.vp;
	let aaa;
	if(report){
		aaa = report.report1;
		report.Title = location.state.report.title;
		report.birthday= location.state.report.birthday;
		report.PatientValue = PatientValue;
		report.createTime= location.state.report.createTime;
	}else{
		aaa = "";
	}
	let records = location.state.report.uid;

	let Prompt = "", Prompts = "", mypathname = "";

	if(report.vp == 0) {
		Prompt = "请到所属医院获取详细报告及调养方案";
	}
	if(report.vp == 1) {
		Prompt = "请到所属医院获取调养方案";
	}

	if(report.isTrust){
		Prompts = "您好，程序显示您的测试结果可信度不足，请您重新如实填写问卷。以下为您五态人格测验的测试结果，请您酌情参考。"
	}
	const delScale = () => {
	    Modal.alert('提示', '确定删除该条纪录？', [
	      { text: '取消', onPress() { } },
	      { text: '确定', onPress: () => {
	        dispatch({
	          type: 'scale/deleteScaleRecord',
	          payload: records,
	        });
	        dispatch(
	            routerRedux.replace({
	               pathname: `/healthy/archives/report`,
	          })
					);
					services.queryReports().then(reports =>{
						dispatch({ type: 'report/save', payload: { reports: reports.data || [] } })
				 })
	      } }
	    ]);
	  };
	const hypreport = {PatientValue, report1: aaa ,createTime:location.state.report.createTime };
	if(location.query.eva == 1) {
		mypathname = location.pathname+"/sheet";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 3? 
					<div>  
					     <WhiteSpace />
							 <ScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 2?
						<div>  
								<WhiteSpace />
								<ScaleReport {...report} />
								<WhiteSpace />
								<ScaleProgrameSelect list={programs} vp={member.vp} />
								<WhiteSpace />
								<ScaleComment comment={comment} />
					</div>
						:(member.vp == 1?
							<div>  
									<WhiteSpace size="lg" />
									<Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
									<WhiteSpace />
									<ScaleReport {...report} />
									<WhiteSpace />
									<ScaleComment comment={comment} />
							</div>  
							: (member.vp == 0?
							  <div>  
									<WhiteSpace size="lg" />
									<Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
								</div>  
							:""
				    )
				))}
			</div>
		)
	}
	if(location.query.eva == 2) {
		mypathname = location.pathname+"/sheet";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 3? 
					<div>  
					     <WhiteSpace />
							 <ScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 2?
					<div>  
					     <WhiteSpace />
							 <ScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} vp={member.vp} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
							<ScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				))}
			</div>
		)
	}
	if(location.query.eva == 3) {
		mypathname = location.pathname+"/sheet/phy";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						   <XinScaleReport {...report} type="phy"/>
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <XinScaleReport {...report} type="phy"/>
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 4) {
		mypathname = location.pathname+"/sheet/pre";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						   <PreScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
					  	<PreScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 5) {
		mypathname = location.pathname+"/sheet/hyp";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 3? 
					<div>  
					     <WhiteSpace />
						 	 <HypScaleReport {...hypreport} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 2?
						<div>  
									<WhiteSpace />
									<HypScaleReport {...report} />
									<WhiteSpace />
									<ScaleProgrameSelect list={programs} vp={member.vp} />
									<WhiteSpace />
									<ScaleComment comment={comment} />
						</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
							<HypScaleReport {...hypreport} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				))}
			</div>
		)
	}
	if(location.query.eva == 6) {
		mypathname = location.pathname+"/sheet/chd";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						 	 <ChdScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <ChdScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 7) {
		return (
			<div>
			     <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						 	 <AlphaReport {...report} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    {/* <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex> */}
				    	<WhiteSpace />
							<AlphaReport {...report} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 8) {
		return (
			<div>
				 <MemberInfo {...member} extra={
							 <button
								 type="button"
								 onClick={delScale}>删除
							 </button>
						 }/>
				 <WhiteSpace />
				 {member.vp == 0?
					 <div>  
							 <WhiteSpace size="lg" />
							 <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					</div>
					:(member.vp == 1?
						<PulseReport {...report} />
						: ""
					) 
				 }
		 </div>
	 )
	}
	if(location.query.eva == 9) {
		return (
			<div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 0?
			    	<div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					 </div>
					 :(member.vp == 1?
					 	<TongueReport {...report} />
					 	: ""
					 ) 
			    }
			</div>
		)
	}
	if(location.query.eva == 10) {
		return (
			<div>
			   <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			   <WhiteSpace />
			    {member.vp == 0?
			    	<div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					 </div>
					 :(member.vp == 1?
					 	<FaceReport {...report} />
					 	: ""
					 ) 
			    }
			</div>
		)
	}
	if(location.query.eva == 11) {
		mypathname = location.pathname+"/sheet/dia";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			     {member.vp == 3? 
					<div>  
					     <WhiteSpace />
							 <DiaScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 2?
						<div>  
								 <WhiteSpace />
								 <DiaScaleReport {...report} />
								 <WhiteSpace />
								 <ScaleProgrameSelect list={programs} vp={member.vp} />
								 <WhiteSpace />
								 <ScaleComment comment={comment} />
						</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
							<DiaScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				))}
			</div>
		)
	}
	if(location.query.eva == 12) {
		mypathname = location.pathname+"/sheet/tcm";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 3? 
					<div>  
					     <WhiteSpace />
						 	 <TcmScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 2?
						<div>  
								 <WhiteSpace />
								 <TcmScaleReport {...report} />
								 <WhiteSpace />
								 <ScaleProgrameSelect list={programs} vp={member.vp} />
								 <WhiteSpace />
								 <ScaleComment comment={comment} />
						</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <TcmScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				))}
			</div>
		)
	}
	if(location.query.eva == 13) {
		mypathname = location.pathname+"sheet/partum";
		return (
			<div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			     {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						   <PartumScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <PartumScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 14) {
		mypathname = location.pathname+"sheet/prepre";
		return (
			<div>
				<MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			     {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						   <PrePreScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <PrePreScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 16) {
		mypathname = location.pathname+"sheet/normal";
		return (
			<div>
				<MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			     {member.vp == 2? 
					<div>  
					     <WhiteSpace />
						   <PrePreScaleReport {...report} />
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <PrePreScaleReport {...report} />
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	if(location.query.eva == 17) {
		mypathname = location.pathname+"/sheet/phy2";
		return (
			 <div>
			    <MemberInfo {...member} extra={
			          <button
			            type="button"
			            onClick={delScale}>删除
			          </button>
			        }/>
			    <WhiteSpace />
			    {member.vp == 2? 
					<div>  
					     <WhiteSpace />
							 <Flex justify="center" style={{color: '#aa4929',}}>{Prompts}</Flex>
							 <WhiteSpace />
						   <XinScaleReport {...report} type="phy2"/>
					     <WhiteSpace />
					     <ScaleProgrameSelect list={programs} />
					     <WhiteSpace />
					     <ScaleComment comment={comment} />
					</div>
					:(member.vp == 1?
					<div>  
					    <WhiteSpace size="lg" />
					    <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
				    	<WhiteSpace />
						  <XinScaleReport {...report} type="phy2"/>
					    <WhiteSpace />
					    <ScaleComment comment={comment} />
					</div>  
				    :(member.vp == 0?
				       <div>  
					      <WhiteSpace size="lg" />
					      <Flex justify="center" style={{color: '#aa4929',}}>{Prompt}</Flex>
					    </div>  
				      : ""
				    )
				)}
			</div>
		)
	}
	return (
			<div>
			    
			</div>
		)
 
}

export default connect(({ report }) => ({
  ...report,
}))(ReportDetailPage);



// { location.state ?<Link to={{
			    // 		          pathname: mypathname,
			    // 		          state: { title: location.state.report.Title, report: location.state.report ,step:2,},
			    // 		        }}>
			    // 		          <List>
			    // 		            <Item
			    // 		              arrow="horizontal">
			    // 		              {"测评详情"}
			    // 		            </Item>
			    // 		          </List>
			    // 		        </Link>
			    // 		        : ""}
